home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk57 / expand / expand.h < prev    next >
C/C++ Source or Header  |  1995-03-19  |  3KB  |  102 lines

  1. /*
  2.  *                              E X P A N D . H
  3.  *
  4.  *  Header file for EXPAND.C, a module in EXPAND.  EXPAND is a file
  5.  *  maintenance utility to decompress files.  It is compatible with the
  6.  *  public domain COMPRESS v4.0 by Spencer W. Thomas, et al.
  7.  *
  8.  *-----------------------------------------------------------------------
  9.  *  Author: Lyle V. Rains
  10.  *      Based on the sources of COMPRESS.C v4.0 by Spencer Thomas, et al.
  11.  *-----------------------------------------------------------------------
  12.  *  Revision History:
  13.  */
  14.  
  15.  
  16. typedef unsigned short CODE;
  17. typedef unsigned short HASH;
  18.  
  19. #define INITBITS    9           /* Various values for bit-length specs  */
  20. #define MAXMAXBITS  16          /* DO NOT CHANGE!!                      */
  21.  
  22. #define CLEAR       ((CODE)256) /* Code sent when tables are cleared    */
  23.  
  24. #define OK          0           /* Result codes from press():           */
  25. #define NOMEM       2           /*   Ran out of memory                  */
  26. #define TOKTOOBIG   3           /*   Token longer than MAXTOKLEN chars  */
  27. #define READERR     4           /*   I/O error on input                 */
  28. #define WRITEERR    5           /*   I/O error on output                */
  29. #define INFILEBAD   6           /*   Infile not in compressed format    */
  30. #define CODEBAD     7           /*   Infile contained a bad token code  */
  31. #define TABLEBAD    8           /*   The tables got corrupted (!)       */
  32.  
  33.  
  34.  
  35. #ifdef EXPAND
  36.  
  37.   /*
  38.    * Internal definitions for use in EXPAND.C
  39.    * They need not be visible to other modules.
  40.    */
  41.  
  42. # include <stdio.h>
  43. # include <assert.h>
  44. # include "system.h"
  45. # include "nextcode.h"
  46.  
  47. # define FIRSTFREE  ((CODE)257) /* First free code for token encoding   */
  48. # define MAXTOKLEN  512         /* Max chars in token; size of buffer   */
  49. # define NULLPTR(type)    ((type FAR *)NULL)
  50.  
  51.   /*
  52.    * Macro to free a pointer with an offset if it is not NULL
  53.    */
  54. # define free_array(type, ptr, offset) \
  55.     if ((ptr) != NULLPTR(type)) { \
  56.       free((ALLOCTYPE FAR *)((ptr) + (offset))); \
  57.       ptr = NULLPTR(type); \
  58.     }
  59.  
  60.   /*
  61.    * Macro to allocate a number of items of a certain type
  62.    */
  63. # define allocx(type, ptr, size) \
  64.     ((ptr) = (type FAR *) malloc((MALLOCARG)(size) * sizeof(type)))
  65.  
  66.   /*
  67.    * Macro to allocate new memory to a pointer with an offset value.
  68.    */
  69. # define alloc_array(type, ptr, size, offset) \
  70.     ( allocx(type, ptr, (size) - (offset)) == NULLPTR(type) \
  71.       ? NOMEM \
  72.       : (((ptr) -= (offset)), OK) \
  73.     )
  74.  
  75. # define suffix(code)        sfx[code]
  76.  
  77. # if (SPLIT_PFX)
  78.     /*
  79.      * We have to split pfx[] table in half, because it is
  80.      * potentially larger than 64k bytes, and the processor
  81.      * can't handle that
  82.      */
  83. #   define prefix(code)   (pfx[(code) & 1][(code)>>1])
  84. # else
  85.     /*
  86.      * Then pfx[] can't be larger than 64k bytes, or we don't care
  87.      * so we don't need to split it.
  88.      */
  89. #   define prefix(code) (pfx[code])
  90. # endif
  91.  
  92. #endif
  93.  
  94.  
  95. /*
  96.  * Externally visible objects in EXPAND.C
  97.  *    extern CONST int Maxbits;
  98.  *    extern int expand(FILE *in, FILE *out, int maxbits, int clearmode);
  99.  */
  100. extern CONST int Maxbits;
  101. extern int expand();
  102.